package com.boil.qz.safekavass.repository;

import com.boil.qz.safekavass.model.WeixinSendredpackEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

/**
 * Created by ChenYong on 2017-11-01.
 * <br>
 * 微信发普通红包实体仓库。
 */
public interface WeixinSendredpackRepository extends JpaRepository<WeixinSendredpackEntity, Long> {
    /**
     * 查询当天最大的商户订单号。
     *
     * @param mch_billno 商户号 + 当天日期
     * @return 当天最大的商户订单号
     */
    @Query(value = "SELECT MAX(T.MCH_BILLNO) AS MAX_MCH_BILLNO FROM TB_WEIXIN_SENDREDPACK T WHERE T.MCH_BILLNO LIKE :mch_billno%", nativeQuery = true)
    String findMaxMchBillno(@Param("mch_billno") String mch_billno);
}